package com.lagou.rpc.common.entity;

/**
 * 简单rpc响应对象构建器
 *
 * @author wlz
 * @date 2020/4/30
 */
public class SimpleRpcResponseBuilder {
    private SimpleRpcResponseBuilder() {

    }

    public static RPCResponseData buildSuccessResponse(byte[] dataContent) {
        RPCResponseData rpcResponseData = new RPCResponseData();
        rpcResponseData.setReturnObject(dataContent);
        rpcResponseData.setOccurExp(false);
        return rpcResponseData;
    }

    public static RPCResponseData buildErrorResponse(Throwable exp) {
        RPCResponseData rpcResponseData = new RPCResponseData();
        rpcResponseData.setOccurExp(true);
        rpcResponseData.setException(exp);
        return rpcResponseData;
    }
}
